<template>
	<view>
		<view class="cu-bar bg-white solid-bottom margin-top" v-if="rss.length >0">
			<view class="action">
				<text class="cuIcon-title text-orange"></text>我的订阅
			</view>
			
		</view>
		<view v-if="rss.length ==0" class="solids-bottom padding-xs flex align-center">
			
			<view class="flex-sub text-center">
				<view class="solid-bottom text-xsl padding">
					<text class=" cuIcon-emojifill text-green"></text>
				</view>
				<view class="padding">尚未订阅任何源请去添加</view>
			</view>
		</view>
		
		<view class="cu-form-group">
			<view class="title">批量导入</view>
			<input placeholder="在这里复制" name="input" @input="inputName" maxlength="1000000"></input>
			<button class="bg-blue" @tap="saveShare">导入</button>
			
		</view>
		<view class="cu-list menu" >
			<view class="cu-item" v-for="(item,index) in rss" >
				<view class="content">
					<text class="cuIcon-discoverfill text-green"></text>
					<text class="text-grey">{{item.name}}</text>
				</view>
				<view class="action" @tap="del(index)">
					<button class="cu-btn round bg-green shadow" >
						<text class="cuIcon-delete" ></text> 删除</button>
				</view>
			</view>
			
			
			</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: '',
				rss:[],
				share:[]
			}
		},
		methods: {
			del(index){
				console.log(index)
				this.rss.splice(index, 1)
				// var value =uni.getStorageSync('rssAddrss');
				// var value = JSON.parse(value)
				// this.rss.slice(index,0)
				uni.setStorageSync('rssAddrss',JSON.stringify(this.rss))
				
			},
			inputName(e) {
				this.name = e.detail.value
			},saveShare(){
				try{
					var list = JSON.parse(this.name)
					
					 uni.setStorageSync('rssAddrss',this.name)
					 uni.showToast({
					 'title':'导入成功！'}
					 )
					 uni.$emit('load',true)
					 
				}catch(e){
					uni.showToast({
					'title':'格式无效'}
					)
				}
				
				
				
			}
		},onReady() {
			var value =uni.getStorageSync('rssAddrss');
			console.log(value)
			this.rss = JSON.parse(value)
		}
	}
</script>

<style>

</style>
